/*
 * tweet_renew.js
 * using ajax techniques
 * written by ryutlis
 * email: ryutlis@ryutlism.org
 * homepage: http://www.ryutlism.org
 */

function load_tweets(type)
{
    var xmlHttp;
    var count=parseInt(document.getElementById("tweetcount").innerHTML);
    try {
        xmlHttp=new XMLHttpRequest();
    } catch(e) {
        try {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        } catch(e1) {
            try {
                xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
            } catch(e2) {
                alert("Your browser doesn't support AJAX");
                return false;
            }
        }
    }
    
    xmlHttp.onreadystatechange=function()
    {
        if (xmlHttp.readyState==4) {
            document.getElementById("table_area").innerHTML=xmlHttp.responseText;
            if ((count+50)<=200) {
                document.getElementById("notify").innerHTML='<a onclick="load_tweets(\'friends\')" id="loadtweets">More</a>';
            } else {
                document.getElementById("notify").innerHTML="";
            }
        } else {
            document.getElementById("notify").innerHTML="<img src='/pics/loader.gif' height='25px' width='25px' />";
        }
    }
    var url="/load_tweets";
    url=url+'?count='+count+'&type='+type;
    xmlHttp.open("GET", url, true);
    xmlHttp.send(null);
    if ((count+50)<=200) {
        document.getElementById("tweetcount").innerHTML=(count+50);
    }
}
